package la.bbs558.entity.enums;

import la.bbs558.exception.MsgException;
import la.bbs558.util.Objs;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;

@Getter
public enum CommonEnum {
    ONE("设置头像", 1),
    TWO("手机验证", 2),
    THREE("邮箱验证", 3),
    COLLECT("收藏", 4);

    private final String desc;
    private final Integer code;

    private final static List<CommonEnum> enums = Arrays.asList(values());

    CommonEnum(String desc, Integer code) {
        this.desc = desc;
        this.code = code;
    }

    public static CommonEnum getByName(String optType){
        for (CommonEnum value : enums) {
            if(Objs.equal(value.name(),optType)){
                return value;
            }
        }
        throw new MsgException("不存在此枚举");
    }
}

